package com.example.demo;

import java.util.Objects;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * <p>
 * 功能描述： 登录控制器
 * </p>
 * 
 * @author lixh
 * @date 2019年1月15日 上午11:11:42
 * @company chinobot
 * @version 1.0
 */
@RestController
public class LoginController {

	@RequestMapping(value = "/api/login", method = { RequestMethod.POST, RequestMethod.GET })
	@ResponseBody
	public String login(HttpServletRequest request, HttpServletResponse response) {
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		JSONObject object = new JSONObject();
		if (!Objects.equals("javalyf", username) || !Objects.equals("123", password)) {
			object.put("message", "登陆失败，详细信息[用户名、密码信息不正确]");
			object.put("code", "404");
		} else {
			object.put("message", "登陆成功");
			object.put("code", "200");
		}
		return object.toJSONString();
	}
}
